package com.kc.business.service.impl;

import com.kc.business.domain.BizProcameraEnterForm;
import com.kc.business.domain.BizUser;
import com.kc.business.mapper.BizProcameraEnterMapper;
import com.kc.business.mapper.BizUserMapper;
import com.kc.business.service.IBizProcameraEnterService;
import com.kc.common.constant.BizConstants;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * TODO
 *
 * @author zhangshuo
 * @version 1.0
 * @date 2020/9/25
 */
@Service
public class BizProcameraEnterServiceImpl implements IBizProcameraEnterService {
    @Resource
    BizProcameraEnterMapper procameraEnterMapper;
    @Resource
    BizUserMapper userMapper;

    /**
     * 拍客入驻列表
     *
     * @param procameraEnterForm
     * @return
     */
    @Override
    public List<BizProcameraEnterForm> getList(BizProcameraEnterForm procameraEnterForm) {
        return procameraEnterMapper.select(procameraEnterForm);
    }

    /**
     * 修改拍客入驻申请
     *
     * @param procameraEnterForm
     * @return
     */
    @Override
    @Transactional
    public int edit(BizProcameraEnterForm procameraEnterForm) {
        if (BizConstants.PASS_VERIFY.equals(procameraEnterForm.getStatus())) {
            BizProcameraEnterForm _procameraEnterForm = procameraEnterMapper.selectByPrimaryKey(procameraEnterForm.getEnterId());
            int useId = _procameraEnterForm.getUserId();
            BizUser bizUser = new BizUser();
            bizUser.setId(useId);
            bizUser.setIsProcamera(BizConstants.YES);
            userMapper.updateByPrimaryKeySelective(bizUser);
        }
        return procameraEnterMapper.updateByPrimaryKeySelective(procameraEnterForm);
    }
}
